package com.heima.item.config;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.heima.item.pojo.Item;
import com.heima.item.pojo.ItemStock;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author dlc
 * @Date 2023/11/28
 * @Description TODO
 * @Version 0.0.1
 */
@Configuration
public class CaffeineConfiguration {

    @Bean
    public Cache<Long, Item> itemCache(){
        // 缓存初始大小100，缓存上限1000
        return Caffeine.newBuilder().initialCapacity(100).maximumSize(1000).build();
    }

    @Bean
    public Cache<Long, ItemStock> itemStockCache(){
        // 缓存初始大小100，缓存上限1000
        return Caffeine.newBuilder().initialCapacity(100).maximumSize(1000).build();
    }
}
